package com.etlmaster.executor.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;

import com.etlmaster.executor.StepStack.MetaEntry;

public class MultiProcessHelper {

	private  BlockingQueue<Object> waitQueue;

	private  BlockingQueue<Object> runningQueue;


	public MultiProcessHelper(int concurrency) {
		waitQueue = new LinkedBlockingQueue<Object>();
		runningQueue = new ArrayBlockingQueue<Object>(concurrency);
	}
	

	public static ExecutorService executor = Executors.newCachedThreadPool();

	
	
	private List<String> cmds = new ArrayList<String>();

	public void submitTask(ThreadEntity task,MetaEntry entry) {
		entry.setFuture(executor.submit(task));

	}
	public boolean isTerminated() {
		return executor.isTerminated();
	}



	public BlockingQueue getWaitQueue() {
		return waitQueue;
	}

	public BlockingQueue getRunningQueue() {
		return runningQueue;
	}

	public List<String> getCmds() {
		return cmds;
	}

	public void setCmds(List<String> cmds) {
		cmds = cmds;
	}
}
